﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;

namespace PloobsEngine.SceneControl
{
    public class OpacityMapPostEffect : IPostEffect
    {
        public OpacityMapPostEffect(String opacityTexture)
        {
            textureName = opacityTexture;
        }

        #region IPostEffect Members

        private string textureName;
        Effect effect = null;
        Texture2D tex;

        public void Draw(IRenderHelper rHelper,  Microsoft.Xna.Framework.GameTime gt, Microsoft.Xna.Framework.Rectangle screenRec, IWorld world)
        {
            ///Draw a quad using the "effect", passing the CurrentImage as a Parameter
            effect.Parameters["opacityMap"].SetValue(tex);
            rHelper.RenderTextureToFullScreenSpriteBatch(PrincipalConstants.CurrentImage, effect);
        }

        public void init(EngineStuff engine)
        {
            ///Load the asset
            effect = EngineStuff.InternalContentManager.GetAsset<Effect>("opacity");
            tex = EngineStuff.CustomContentManager.GetAsset<Texture2D>(textureName);
            
        }

        #endregion
    }
}
